// 路由文件
import Vue from 'vue'
// 引入vueRouter
import VueRouter from 'vue-router'

// Vue提供的加载插件方法
Vue.use(VueRouter)

// 导入路由渲染的组件
import Film from '../views/Film'
import filmRouter from './routes/film';
// import Detail from '../views/Detail'
import Comingsoon from '../views/Film/Comingsoon'
import Nowplaying from '../views/Film/Nowplaying'
// 定义路由规则
const rules = [
  filmRouter,
  {
    // http://xxx/#/home
    // 路径 规则  uri
    path: '/films',
    // 渲染的组件是谁
    component: Film,
    children:[
      {
        path:'nowplaying',
        component:Nowplaying,
      },
      {
        path:'comingsoon',
        component: Comingsoon,
      },
      {
        path:'/film',
        redirect:'nowplaying'
      }
    ]
  },
  //电影详情动态路由
  {
    name:'detail',
    path:'/detail/:id',
    component:Detail
  }
]

// 创建VueRuter实例
const router = new VueRouter({
  // 路由模式  hash history  默认的规则就为hash
  mode: 'history',
  routes: rules
})

// 导出
export default router
